package com.iflytek.uoamp.agent.monitor.sender.schedual;

import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit;

import com.iflytek.uoamp.agent.monitor.sender.biz.AbsSender;

public class ScheduleNoSend {
	private final ScheduledExecutorService scheduExec = Executors.newScheduledThreadPool(1);

	private AbsSender sender = null;

	public ScheduleNoSend(AbsSender sender) {
		this.sender = sender;
	}

	// 定时执行任务
	public void addOneTask() {
		Runnable task = new ScheduleRunning(sender);
		scheduExec.scheduleWithFixedDelay(task, sender.getConfig().getFirstIntervalDelay(), sender.getConfig().getSchedualIntervalTime(), TimeUnit.SECONDS);
	}

	public void shutDown() {
		scheduExec.shutdown();
	}
}
